<template>
  <div class="search">
    <f-drawer ref="taskTodoDrawer" :title="drawerTitle" width="50%" @submit="handleSubmit" @visibleChange="visibleChange" :showFooter="false">
      <a-tabs @tabClick="tabClick" v-model="activeName" :animated='false'>
        <a-tab-pane tab="订单审核" key="form1">
          <task-todo-form ref="form1" v-if="drawerVisible" @callback="closeDrawer" :taskHandlerName='this.taskHandlerName' :handlerName="this.handlerName"></task-todo-form>
        </a-tab-pane>
        <a-tab-pane tab="审核历史" key="form2">
          <process-comment ref="form2" v-if="drawerVisible"></process-comment>
        </a-tab-pane>
      </a-tabs>
    </f-drawer>
  </div>
</template>
<script>
  import taskTodoForm from './tasktodo_form.vue'
  import ProcessComment from '../components/processComment'
  import api from '../processInstance/js/api'

  export default {
    name: 'taskTodoDrawer',
    props: {
      handlerName: {
        type: String,
        default: ''
      },
      taskHandlerName: {
        type: String,
        default: ''
      },
    },
    data() {
      return {
        api: Object.assign(api, this.api),
        drawerVisible: false,
        activeName: 'form1',
        forms: [
          'form1',
          'form2',
          'form3'
        ],
        comments: [],
        task: {},
        title: '查看详情',
        imagePath: '',
        isShowProcessInstanceForm: false,
        generateStartFormVisible: false,
        formJson: undefined,
        variables: undefined,
        showBusinessKey: false,
        businessKey: undefined
      }
    },
    methods: {
      showDrawer(data) {
        if (data && data.taskId) {
          this.task = data
        }
        this.$refs['taskTodoDrawer'].show()
        this.tabClick('form1')
      },
      closeDrawer(refreshTable) {
        this.$refs.taskTodoDrawer.close()
        if (refreshTable) {
          this.$emit('success')
        }
      },
      handleSubmit(callback) {
        this.$refs[this.current].handleSubmit(callback)
      },
      visibleChange(drawerVisible) {
        this.drawerVisible = drawerVisible
      },
      tabClick(name) {
        this.activeName = name
        if (this.current === 'form1') {
          this.title = this.isEdit ? '流程审核' : '审核历史'
        }
        this.$nextTick(() => {
          this.$refs[this.activeName].setData(this.task)
        })
      }
    },
    computed: {
      drawerTitle: function() {
        return this.title
      }
    },
    created() {
    },
    components: { taskTodoForm, ProcessComment }
  }
</script>

<style scoped lang="less" rel="stylesheet/less">

</style>
